package com.yq.backend.controller;

import com.yq.backend.dto.CardUserDto;
import com.yq.backend.pojo.CardUser;
import com.yq.backend.pojo.Result;
import com.yq.backend.service.MemberService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @descriptions: 活动管理
 * @author: yunqiang
 * @date: 2022/5/3 11:27
 */
@Api(tags = {"会员管理：会员管理控制类"})
@RestController
@RequestMapping("/api/v1/member")
public class MemberController {

    @Autowired
    private MemberService memberService;


    @ApiOperation(value = "等级列表")
    @PostMapping("/getGrades")
    public Result getGrades(String name, int pageSize, int pageNow) {
        return this.memberService.getGrades(name, pageSize, pageNow);
    }

    @ApiOperation(value = "全量等级")
    @GetMapping("/allGrade")
    public Result allGrade() {
        return this.memberService.allGrade();
    }

    @ApiOperation(value = "会员列表")
    @PostMapping("/getMembers")
    public Result getMembers(@RequestBody CardUserDto cardUserDto) {
        return this.memberService.getMembers(cardUserDto);
    }

    @ApiOperation(value = "新增会员")
    @PostMapping("/addMember")
    public Result addMembers(@RequestBody CardUser cardUser) {
        return this.memberService.addMembers(cardUser);
    }

    @ApiOperation(value = "修改会员")
    @PostMapping("/upMember")
    public Result upMembers(@RequestBody CardUser cardUser) {
        return this.memberService.upMembers(cardUser);
    }

    @ApiOperation(value = "删除会员")
    @GetMapping("/delMembers/{id}")
    public Result delMembers(@PathVariable String id) {
        return this.memberService.delMembers(id);
    }

    @ApiOperation(value = "根据id查询会员")
    @GetMapping("/members/{id}")
    public Result getmembersId(@PathVariable Integer id) {
        return this.memberService.getmembersId(id);
    }
}
